package com.ckh.springboot.controller;

import com.ckh.springboot.common.Result;
import com.ckh.springboot.entity.ExamSchedule;
import com.ckh.springboot.service.IExamScheduleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/examSchedule")
@CrossOrigin(origins = "http://localhost:9528")
public class ExamScheduleController {

    @Resource
    private IExamScheduleService examScheduleService;

    @GetMapping("/list")
    public Result list() {
        List<ExamSchedule> examSchedules = examScheduleService.list();
        return Result.success(examSchedules);
    }

    @PostMapping("/create")
    public Result create(@RequestBody ExamSchedule examSchedule) {
        examScheduleService.save(examSchedule);
        return Result.success();
    }
    
    @PostMapping("/update")
    public Result update(@RequestBody ExamSchedule examSchedule) {
        examScheduleService.updateById(examSchedule);
        return Result.success();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        examScheduleService.removeById(id);
        return Result.success();
    }
}